package io.gitee.pkmer.http;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * @author 胖卡
 * @version 1.0.0
 * @date 2024/8/13
 */
public class GetBaiduMain {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder().url("https://www.baidu.com")
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                System.out.println("Response code: " + response.code());
                System.out.println("Response body: " + response.body().string());
            } else {
                System.out.println("Request failed with code: " + response.code());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
